<template>
	<view class="wrap p-2">
		<div>
			<u-button  type="primary" @click="toAdd">添加活动</u-button>
		</div>
		<div class="events-list flex-auto overflow-auto h-10">
			<div class="event-list-item" v-for="(item,index) in event_list" :key="index" @click="view(item._id)">
				<div v-for="(sitem,i) in item.fileList" :key="i" class="img-box" v-if="item.fileList">
					<u-image width="100%" height="100%" :src="sitem.url"></u-image>
				</div>
				<div class="main-box">
					<p class="title">{{item.name}}</p>
					<p class="info">{{item.info}}</p>
					<div class="item-other">
						<p class="addr">会议室:{{item.address}}</p>
						<p class="date">时间:{{$utils.timestampToTime(item.create_date)}}</p>
					</div>
					<!-- <p>
						<u-button @click="edit(item._id)">修改</u-button>
					</p> -->
				</div>

			</div>
		</div>
		<m-tab-bar></m-tab-bar>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				event_list: []
			}
		},
		onLoad() {
			// location.reload()
		},
		onShow() {
			this.getList()
		},
		methods: {
			view(id) {
				uni.navigateTo({
					url: './operation?id=' + id,
				});
			},
			toAdd() {
				uni.navigateTo({
					url: './operation',
				});
			},
			getList() {
				uni.showLoading({
					title: '加载中...'
				})
				this.$reqFun.req("events", {
					action: 'list'
				}).then(res => {
					uni.hideLoading()
					this.event_list = res.result.data
				})
				// uniCloud.callFunction({
				// 	name: "events",
				// 	data: {
				// 		action: 'list'
				// 	},
				// 	success: (res) => {
				// 		uni.hideLoading()
				// 		console.log(res)
				// 		this.event_list = res.result.data
				// 	},
				// 	fail: (err) => {
				// 		uni.hideLoading()
				// 		console.log(err)
				// 	}
				// })
			}
		}
	}
</script>

<style lang="scss" scoped>
	@import "./events.scss";
</style>
